/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "RgnDialog.h"
#include "afxcmn.h"
#include "MMachineInfo.h"
#include "MKOuiIabList.h"
#include "MKMcast4List.h"
#include "MPortDescriptionList.h"

#include "WorkDefinitions.h"

#include "MGlobalInfo.h"

#include "MDHCPInfoDesc.h"
#include "MNTPDecoder.h"
#include "MWmiNames.h"
#include "MGxRPDecoder.h"
#include "MSTPDecoder.h"
#include "MCDPDecoder.h"
#include "MDTPDecoder.h"

/*! \brief The class behind the Details window
*/

class DlgDetails : public CRgnDialog
{
	DECLARE_DYNAMIC(DlgDetails)

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	CString DwTimeToDHMS(DWORD);

	CString DwToIpStr(DWORD);

	WorkDefinitions wd;
	CString GetMethodName(WorkMethodType);

	bool AddInfoMAC(MMachineInfo*, HTREEITEM);
	bool AddNetBiosNames(MMachineInfo*, HTREEITEM, bool);
	bool AddSharesInfo(MMachineInfo*, HTREEITEM, bool);
	bool AddSnmpSysInfo(MMachineInfo*, HTREEITEM, bool);
	bool AddInfoDHCP(MMachineInfo*, HTREEITEM, bool);
	bool AddPromiscResults(MMachineInfo*, HTREEITEM, bool);
	bool AddIgmpInfo(MMachineInfo*, HTREEITEM, bool);
	bool AddGxRPInfo(MMachineInfo*, HTREEITEM, bool);
		bool AddGxRPPacket(MGxRPPacket*, HTREEITEM, bool);
	bool AddCDPInfo(MMachineInfo*, HTREEITEM, bool);
		bool AddCDPPacket(MCDPPacket*, HTREEITEM, bool);
	bool AddSTPInfo(MMachineInfo*, HTREEITEM, bool);
	bool AddDTPInfo(MMachineInfo*, HTREEITEM, bool);
		bool AddDTPPacket(MDTPPacket*, HTREEITEM, bool);
	bool AddPortsForMethod(MMachineInfo*, HTREEITEM, WorkMethodType, bool);
	bool AddDnsNames(MMachineInfo*, HTREEITEM, bool);

	int qfeCnt;
	int grpCnt;
	int usrCnt;
	bool AddWmiInfo(MWmiData*, HTREEITEM, bool);
		bool AddWmiInfoOS(MWmi_Win32_OperatingSystem*, HTREEITEM, bool);
		bool AddWmiInfoQFE(MWmi_Win32_QuickFixEngineering*, HTREEITEM, bool);
		bool AddWmiInfoShares(MWmi_Win32_Share*, HTREEITEM, bool);
		bool AddWmiInfoDiskDrive(MWmi_Win32_DiskDrive*, HTREEITEM, bool);
		bool AddWmiInfoDiskPart(MWmi_Win32_DiskPartition*, HTREEITEM, bool);
		bool AddWmiInfoProcessor(MWmi_Win32_Processor*, HTREEITEM, bool);
		CString GetFriendlyProcessorName(MWmi_Win32_Processor*);
		bool AddWmiInfoPhysicalMem(MWmi_Win32_PhysicalMemory*, HTREEITEM, bool);
		unsigned __int64 GetWmiInfoPhysicalMem(MWmi_Win32_PhysicalMemory*);
		bool AddWmiInfoCDROM(MWmi_Win32_CDROMDrive*, HTREEITEM, bool);
		bool AddWmiInfoVideoController(MWmi_Win32_VideoController*, HTREEITEM, bool);
		bool AddWmiInfoDesktopMonitor(MWmi_Win32_DesktopMonitor*, HTREEITEM, bool);
		bool AddWmiInfoUserAccount(MWmi_Win32_UserAccount*, HTREEITEM, bool);
		bool AddWmiInfoGroup(MWmi_Win32_Group*, HTREEITEM, bool);
		bool AddWmiLoggedUser(MWmi_Win32_LoggedUser*, HTREEITEM, bool);

	bool UpdateInfoDone(bool);

	bool AddCounterTreeItem(HTREEITEM, CString, unsigned int);

	bool AddTextItem(HTREEITEM, CString, CString);

	bool UpdateGlobalInfoDone(bool);

	MDHCPInfoDesc    infoDescDHCP;
	MNTPDecoder      mNTPDecoder;
	MWmiNames        wmiNames;
	MGxRPDecoder     mGxRPDecoder;
	MSTPDecoder      mSTPDecoder;
	MCDPDecoder      mCDPDecoder;
	MDTPDecoder      mDTPDecoder;

	CTreeCtrl theTree;
	virtual void ResizeChilds(void);

	virtual BOOL OnInitDialog();
	virtual void OnOK();
	virtual void OnCancel();

	DECLARE_MESSAGE_MAP()

public:
	DlgDetails(CWnd* pParent = NULL);
	virtual ~DlgDetails();

	enum { IDD = IDD_DLG_DETAILS }; // Dialog Data

	MKOuiIabList         *vendorList;
	MKMcast4List         *mcast4List;
	MPortDescriptionList *portDescList;

	bool UpdateInfo(MMachineInfo*);
	bool UpdateGlobalInfo(MGlobalInfo*);
};
